<?php
	include "common.php";
	session_start();
	error_reporting(0);
	if($_SESSION['logInCheck']!=1){
		header('Location: index.php?loginInfo=false');
	}
	$userLink = $_SESSION['userLink'];	
	if($userLink!="hrpage.php"){
		echo "Sorry, You have no right to visit this page!!";
		exit;
	}			
	$ID = $_SESSION['id'];
	$supervisor = $_SESSION['supervisor'];
	$userName = $_SESSION['userFname'];
	$role = $_SESSION['role'];
	$userSql = "SELECT * FROM user WHERE e_id = '$supervisor'";
	$userSqlQuery = mysql_query($userSql);
	$userSqlQueryResult = mysql_fetch_assoc($userSqlQuery);	
	$supervisorFname = $userSqlQueryResult['f_name'];
	$supervisorLname = $userSqlQueryResult['l_name'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="index.css" type="text/css" />
<link rel="stylesheet" href="show_report.css" type="text/css" />
<link rel="icon" type="image/ico" href="images/favicon.ico"></link> 
<link rel="shortcut icon" href="images/favicon.ico"></link>
<link rel="stylesheet" type="text/css" href="jquery.alerts.css" />
<script src="jquery.js" type="text/javascript"></script>
<script src="jquery-ui.js" type="text/javascript"></script>
<script src="jquery.ui.draggable" type="text/javascript"></script>
<script src="jquery.alerts.js" type="text/javascript"></script>
<script src="curvycorners.src.js" type="text/javascript"></script>
<script src="login.js" type="text/javascript"></script>
<title><?php echo "Welcome to ".$userFname." ".$userLname; ?></title>
</head>

<body>
<div class="main_div_other">
	<p><img src="images/creato_logo.jpg" /></p>
    <p id="creatobd">www.creatobd.com</p>
    <p id="date"><script>document.write(new_month+" "+new_date+", "+old_date.getFullYear()+" || "+new_day);</script></p>
    <div class="other_page_icons">
    	<div class="new_notification">
        	<img src="images/arrow_up.JPG" /><?php if ($notification >0){?><p>You have<?php echo " ".$notification." ";?>new notification</p><?php }?>
        </div><!--end of new_notification-->
    	<ul>
        	<a href="hrpage.php"><li><div id="home"></div><p>home</p><p class="present_class"><img src="images/arrow_up.JPG" /></p></li></a>
            <a href="hr_employee.php"><li><div id="employee"></div><p>employee</p><p class="present_class"><img src="images/arrow_up.JPG" /></p></li></a>
            <a href="hr_onduty.php"><li><div id="onduty"></div><p>on duty</p><p class="present_class"><img src="images/arrow_up.JPG" /></p></li></a>
            <a href="hr_attendance.php"><li><div id="attendance"></div><p>attendance</p><p class="present_class"><img src="images/arrow_up.JPG" /></p></li></a>
            <a href="hr_leave.php"><li><div id="leave"></div><p>leave</p><p class="present_class"><img src="images/arrow_up.JPG" /></p></li></a>
            <a href="hr_notification.php"><li><div id="notification"></div><p>notification</p><p class="present_class"><img src="images/arrow_up.JPG" /></p></li></a>
            <a href="hr_black_box_message.php"><li><div id="blackbox"></div><p>black box</p><p class="present_class"><img src="images/arrow_up.JPG" /></p></li></a>
            <a href="#"><li><div id="hrpolicy"></div><p>hr policy</p><p class="present_class"><img src="images/arrow_up.JPG" /></p></li></a>
            <a href="index.php"><li><div id="logout"></div><p>log out</p><p class="present_class"><img src="images/arrow_up.JPG" /></p></li></a>
        </ul>
    </div><!-- end of other_page_icons-->
    
</div><!-- end of main_div_other-->

<div class="human_portal">
  		<p>creato human resourse portal</p>
</div><!-- end of human_portal-->
<div class="page_content">
    	<?php				
		$notificationSql = "SELECT * FROM notification WHERE e_id = '$eid'";
		$notificationSqlQuery = mysql_query($notificationSql);
		$notificationSqlQueryResult = mysql_fetch_assoc($notificationSqlQuery);
						
		$status = $notificationSqlQueryResult['Status'];
		$approvalType = $notificationSqlQueryResult['Type'];
		$reason = $notificationSqlQueryResult['Reason'];
		$supervisor = $notificationSqlQueryResult['supervisor'];
	?>
		<table cellpadding="0" cellspacing="0">
    		<tr class="table_header_1"  valign="top" width="300px">
				<td><p>Approval Notification From The Supervisor</p></td>		
			</tr>
			<tr valign="top" class="table_header_2">
				<td>
					<?php 
						if ($status == 'ACCEPTED')
							{
								echo "Congratulations ...Your Notification Was Accepted.<br><br>";
							}
						else if ($status ==2)
							{
								echo "Your Notification is Pending For Approval From Your Supervisor.<br><br>";
							}
						else if ($status == 'REJECTED')
							{
								echo "Sorry...Your Approval Was Rejected...<br><br>";
							}
						else
							{
								echo "You Do not Have Any Notification for Approval From Your Supervisor.";
							}
					?>
				</td>
			</tr>
		</table>
			<table cellpadding="0" cellspacing="0">
			<br /><br />
		   		<tr valign="top" class="table_header_1">
					<td colspan="5"><p>Pending For Your Approval</p></td>
				</tr>
				<tr valign="top" class="table_header_2">
					<td width="100px"><p>First Name</p></td>
					<td width="100px"><p>Last Name</p></td>
					<td width="100px"><p>Apply Type</p></td>
					<td width="100px"><p>Accept</p></td>
					<td width="100px"><p>Reject</p></td>
				</tr>
			<?php 
				$sql = "SELECT * FROM notification WHERE supervisor = '$ID' and status='2' ";
				$ifSupervisor = mysql_query($sql);
				
				while ($ifSupervisorResult = mysql_fetch_array($ifSupervisor)){
					$supervisor = $ifSupervisorResult['supervisor'];
					$status = $ifSupervisorResult['Status'];
					$approvalType = $ifSupervisorResult['Type'];
					$referId = $ifSupervisorResult['reference_id'];
					
					$_SESSION['apply_type'] = $approvalType;
						
					//approval_type table SQL
					$approvalSql = "SELECT * FROM $approvalType WHERE id = '$referId'";
					$approvalSqlQuery = mysql_query($approvalSql);
						
					$sqlResult = mysql_fetch_assoc($approvalSqlQuery);
					
					$applier = $sqlResult['e_id'];
					$applyType = $sqlResult['Type'];
					$Reason = $sqlResult['Reason'];
					
					$_SESSION['applier'] = $applier;
					
					$userSql = "SELECT *  FROM user WHERE e_id = '$applier'";
					$userSqlQuery = mysql_query($userSql);
					$userSqlQueryResult = mysql_fetch_assoc($userSqlQuery);
					
					$fName = $userSqlQueryResult['f_name'];
					$lName = $userSqlQueryResult['l_name'];
		   ?>
		   <tr valign="top" class="table_header_3">
		   		<td width="100px"><p><?php echo $fName;?></p></td>
				<td width="100px"><p><?php echo $lName;?></p></td>
				<td width="100px"><p><?php echo $applyType;?></p></td>
				<td width="100px"><p><a href="approval.php?id=1">Accept</a></p></td>
				<td width="100px"><p><a href="approval.php?id=0">Reject</a></p></td>
		   </tr>	
		</table>	
	<?php
		}
	?>
    </div><!-- end of page_content -->
</body>
</html>


